<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/9
 * Time: 15:35
 */
if (!defined('ACCESS')) {
    exit('Access denied.');
}

class AdminDbConfig extends Base
{

    private static $table_name = 'dbs_config';
    // 查询字段
    private static $columns = array('id', 'website', 'website_name');

    public static function getTableName()
    {
        return self::$table_name;
    }

    public static function getAll()
    {
        $db = self::__instance();
        $list = $db->select(self::getTableName(), self::$columns);
        return $list;
    }

    public static function getSiteForOptions()
    {
        $list = self::getAll();
        foreach ($list as $v) {
            $websites[] = $v['website'];
        }

        foreach ($websites as $site) {
            $options_array [$site] = $site;
        }

        return $options_array;
    }


    public static function getSiteNameBySite($url)
    {
        $db = self::__instance();
        $condition = array("website" => $url);
        $list = $db->get(self::getTableName(), self::$columns, $condition);
        return $list;
    }
}




